
<template>
  <div class="device-management">
    <div class="card-container">
      <div class="card">
        <div class="card-header">设备情况</div>
        <div class="card-body">
          <div class="stat-container">
            <div class="stat-item">使用统计</div>
            <div class="stat-item">
              <span class="stat-label">全部设备</span>
              <span class="stat-value">276台</span>
            </div>
            <div class="stat-item">
              <span class="stat-label">在用设备</span>
              <span class="stat-value">260台</span>
            </div>
            <div class="stat-item">
              <span class="stat-label">闲置设备</span>
              <span class="stat-value">10台</span>
            </div>
            <div class="stat-item">
              <span class="stat-label">停用设备</span>
              <span class="stat-value">6台</span>
            </div>
          </div>

          <div class="stat-container">
            <div class="stat-item">激活情况（在用设备）</div>
            <div class="stat-item activated">
              <span class="stat-label">已激活设备</span>
              <span class="stat-value">212台</span>
            </div>
            <div class="stat-item unactivated">
              <span class="stat-label">未激活设备</span>
              <span class="stat-value">48台</span>
            </div>
          </div>

          <div class="stat-container">
            <div class="stat-item">运行状态（已激活设备）</div>
            <div class="stat-item normal">
              <span class="stat-label">正常设备</span>
              <span class="stat-value">208台</span>
            </div>
            <div class="stat-item faulty">
              <span class="stat-label">故障设备</span>
              <span class="stat-value">4台</span>
            </div>
          </div>
        </div>
      </div>

      <div class="card">
        <div class="card-header">待办事项</div>
        <div class="card-body">
          <div class="todo-item">
            <div class="todo-label">待激活</div>
            <div class="todo-value todo-value-red">2</div>
          </div>
          <div class="todo-item">
            <div class="todo-label">待安装</div>
            <div class="todo-value todo-value-gray">0</div>
          </div>
          <div class="todo-item">
            <div class="todo-label">型号补充</div>
            <div class="todo-value todo-value-gray">0</div>
          </div>
          <div class="todo-item">
            <div class="todo-label">安装地点补充</div>
            <div class="todo-value todo-value-orange">1</div>
          </div>
        </div>
      </div>
    </div>

    <div class="chart-container">
      <div class="chart-card">
        <div class="card-header">设备安装分布统计</div>
        <div class="map-container">
          <!-- 这里应该放置地图组件 -->
          <div class="map-placeholder" id="map"></div>
          <div class="legend">
            <div class="legend-item">
              <span class="legend-color" style="background-color: #1e88e5"></span>
              <span class="legend-text">100台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #42a5f5"></span>
              <span class="legend-text">80台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #64b5f6"></span>
              <span class="legend-text">60台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #90caf9"></span>
              <span class="legend-text">40台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #bbdefb"></span>
              <span class="legend-text">20台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #e3f2fd"></span>
              <span class="legend-text">10台以上</span>
            </div>
            <div class="legend-item">
              <span class="legend-color" style="background-color: #f5f5f5"></span>
              <span class="legend-text">1台以上</span>
            </div>
          </div>
        </div>
      </div>

      <div class="chart-card">
        <div class="card-header" style="display: flex; justify-content: space-between; align-items: center;">
          <span>在用设备排行</span>
          <span>单位：台</span>
        </div>
        <div class="chart-body">
          <div class="bar-chart">
            <div class="bar-item">
              <span class="bar-label">光刻机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 84%"></div>
              </div>
              <span class="bar-value">84</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">刻蚀机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 75%"></div>
              </div>
              <span class="bar-value">75</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">薄膜沉积设备</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 65%"></div>
              </div>
              <span class="bar-value">65</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">离子注入机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 40%"></div>
              </div>
              <span class="bar-value">40</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">机械抛光</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 35%"></div>
              </div>
              <span class="bar-value">35</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">清洗机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 21%"></div>
              </div>
              <span class="bar-value">21</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">氧化炉</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 18%"></div>
              </div>
              <span class="bar-value">18</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">晶圆切割机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 15%"></div>
              </div>
              <span class="bar-value">15</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">晶圆累融机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 11%"></div>
              </div>
              <span class="bar-value">11</span>
            </div>

            <div class="bar-item">
              <span class="bar-label">测试机</span>
              <div class="bar-container">
                <div class="bar-fill" style="width: 8%"></div>
              </div>
              <span class="bar-value">8</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted } from 'vue';

onMounted(() => {
  // 这里可以添加地图初始化代码
  console.log('设备管理系统已加载');
})
</script>

<style scoped>
.device-management {
  padding: 20px;
}

.card-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-header {
  padding: 16px;
  font-size: 16px;
  font-weight: bold;
  border-bottom: 1px solid #f0f0f0;
}

.card-body {
  padding: 16px;
}

.stat-container {
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
}

.stat-label {
  color: #666;
}

.stat-value {
  font-weight: bold;
  color: #333;
}

.activated {
  background-color: #FFF3E0;
}

.unactivated {
  background-color: #FFFDE7;
}

.normal {
  background-color: #E8F5E9;
}

.faulty {
  background-color: #FFEBEE;
}

.todo-item {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid #f0f0f0;
}

.todo-label {
  color: #666;
}

.todo-value {
  font-weight: bold;
  font-size: 24px;
  margin-left: 10px;
}

.todo-value-red {
  color: #F44336;
}

.todo-value-gray {
  color: #9E9E9E;
}

.todo-value-orange {
  color: #FF9800;
}

.map-container {
  height: 300px;
  position: relative;
}

.map-placeholder {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
  border-radius: 4px;
}

.legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 5px;
}

.legend-text {
  font-size: 12px;
  color: #666;
}

.chart-body {
  padding: 16px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bar-chart {
  height: 340px;
}

.bar-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.bar-label {
  width: 120px;
  text-align: right;
  padding-right: 15px;
  color: #666;
}

.bar-container {
  flex: 1;
  height: 20px;
  background-color: #e9ecef;
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background-color: #3498db;
  border-radius: 10px;
}

.bar-value {
  width: 40px;
  text-align: left;
  padding-left: 15px;
  font-weight: bold;
}

/* 响应式调整 */
@media (max-width: 992px) {
  .card-container, .chart-container {
    grid-template-columns: 1fr;
  }
}
</style>